package com.example.peibei.ui.activity;

import android.widget.TextView;

import com.dingtao.common.bean.Spread;
import com.dingtao.common.core.DataCall;
import com.dingtao.common.core.WDActivity;
import com.dingtao.common.core.exception.ApiException;
import com.dingtao.common.util.SPUtils;
import com.example.peibei.R;
import com.example.peibei.base.SpConstant;
import com.example.peibei.service.presenter.SpreadPresenter;

import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class TuiguangGuizeActivity extends WDActivity {
    @BindView(R.id.tv_person_one)
    TextView tv_person_one;
    @BindView(R.id.tv_person_two)
    TextView tv_person_two;
    @BindView(R.id.tv_person_three)
    TextView tv_person_three;
    @BindView(R.id.tv_scale_one)
    TextView tv_scale_one;
    @BindView(R.id.tv_scale_two)
    TextView tv_scale_two;
    @BindView(R.id.tv_scale_three)
    TextView tv_scale_three;

    private SPUtils spUtils;
    private String token;
    private SpreadPresenter spreadPresenter;

    @Override
    protected int getLayoutId() {
        return R.layout.activity_tuiguang_guize;
    }

    @Override
    protected void initView() {
        spUtils = new SPUtils(this, SpConstant.USER_TOKEN);
        token = spUtils.getString(SpConstant.USER_TOKEN);
        spreadPresenter = new SpreadPresenter(new SpreadCall());
    }

    @OnClick(R.id.iv_back)
    public void back() {
        finish();
    }

    @Override
    protected void onResume() {
        super.onResume();
        spreadPresenter.reqeust("Bearer " + token);
    }

    class SpreadCall implements DataCall<Spread> {

        @Override
        public void success(Spread data, Object... args) {
            List<Spread.DescListDTO> descList = data.getDescList();
            tv_person_one.setText(descList.get(0).getConditions() + "");
            tv_scale_one.setText(descList.get(0).getScale() + "");
            tv_person_two.setText(descList.get(1).getConditions() + "");
            tv_scale_two.setText(descList.get(1).getScale() + "");
            tv_person_three.setText(descList.get(2).getConditions() + "");
            tv_scale_three.setText(descList.get(2).getScale() + "");
        }

        @Override
        public void fail(ApiException e, Object... args) {

        }
    }

    @Override
    protected void destoryData() {

    }
}
